home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / c1.zip / SWITCH.C < prev    next >
Text File  |  1987-06-18  |  4KB  |  102 lines

  1.  
  2. /******************************************************************************
  3. *******************************************************************************
  4.  
  5.  
  6.                      THIS UTILITY SELECTS THE ACTIVE DISPLAY
  7.              USAGE:  switch [MONITOR] [MODE]
  8.  
  9.                      [MONITOR] = monochrome or color.
  10.                         type in either mono or monochrome,
  11.                                 or col or color for color display.
  12.  
  13.                      [MODE] = (FOR COLOR ONLY)
  14.                         0     40 * 25 BLACK AND WHITE
  15.                         1     40 * 25 COLOR
  16.                         2     80 * 25 BLACK AND WHITE
  17.                         3     80 * 25 COLOR
  18.                         4     320 * 200 COLOR  (MED. RES.)
  19.                         5     320 * 200 BLACK AND WHITE  (MED. RES.)
  20.                         6     640 * 200 BLACK AND WHITE  (HIGH RES.)
  21.  
  22. *******************************************************************************
  23. ******************************************************************************/
  24.  
  25.  
  26. #include "stdio.h"
  27. #include "conio.h"
  28. #include "utility.h"
  29. #include "screen.h"
  30. #include "string.h"
  31. #include "ctype.h"
  32. main(argc, argv)
  33. int argc;
  34. char **argv;
  35. {
  36.         ADS equip_flag, new_equip_flag;
  37.         int comlinptr, ax, bx, cx, dx, mode, columns, page, x;
  38.         unsigned flag;
  39.         char c, *comlin1, *calloc();
  40.         comlin1 = calloc(40, 1);/*allocate 40 bytes for comlin1*/
  41.         x = 0;
  42.  
  43.         if(argc < 2)/*check for command line argument*/
  44.                 utabort("NO COMMAND LINE ARGUMENT  switch [MONITOR] [MODE]");
  45.  
  46.         equip_flag.s = 0x0040;/*rom bios data segment*/
  47.         equip_flag.r = 0x0010;/*offset*/
  48.         new_equip_flag.s = _defds;/*default data segment*/
  49.         new_equip_flag.r = &flag;
  50.  
  51.         strcpy(comlin1, argv[1]);/*move argv1 to comlin1 for convert to LC*/
  52.         while((c = comlin1[x]) != '\0'){/*convert if upper case to lower*/
  53.                 comlin1[x++] = tolower(c);
  54.         }
  55.  
  56.         strcpy(argv[1], comlin1);/*return changed string to  argv[1]*/
  57.         free(comlin1);/*free allocated space of comlin1*/
  58.  
  59.         if((stsindex("mono", argv[1])) == 0){/*switch to monochrome*/
  60.                 if(!scmode(&mode, &columns, &page))/*check not on monochrome*/
  61.                         utabort("ALREADY ON MONOCHROME ADAPTER");
  62.                 outp(0x3d8, 00);/*deselect video enable on 6845*/
  63.                 bios(17, &ax, &bx, &cx, &dx);/*get current flag into ax*/
  64.                 flag = ax | 0x0030;/*set equipment flag to monochrome*/
  65.                 utslmove(&new_equip_flag, &equip_flag, 4);/*return flag*/
  66.                 screset(0);/*bios set mode call*/
  67.                 exit();
  68.         }
  69.  
  70.         if((stsindex("col", argv[1])) == 0){/*switch to color display*/
  71.              if(argc != 3 || argc > 3)/*correct number of arguments*/
  72.                 utabort("NO COMMAND LINE ARGUMENT  switch [MONITOR] [MODE]");
  73.              if(scmode(&mode, &columns, &page))/*check not on color already*/
  74.                       utabort("ALREADY ON COLOR ADAPTER");
  75.              clear_screen();/*clear mono screen*/
  76.              utslmove(&equip_flag, &new_equip_flag, 4);
  77.              flag = flag ^ 0x0030;/*erase old display info*/
  78.              flag = flag | 0x0020;/*set as 80 * 25 color card*/
  79.              utslmove(&new_equip_flag, &equip_flag, 4);/*return flag*/
  80.              stcd_i(argv[2], &comlinptr);/*set com line arg to integer*/
  81.              screset(comlinptr);/*set mode from command line*/
  82.              exit();
  83.         }
  84.         utabort("NO COMMAND LINE ARGUMENT  switch [MONITOR] [MODE]");
  85. }
  86.  
  87.  
  88. clear_screen()/*clears monochrome screen*/
  89. {
  90.  
  91.         int ax, bx, cx, dx;
  92.         ax = 0x0600;/*set ah = 6  scroll screen*/
  93.         bx = 0x0700;/*attribute 7*/
  94.         cx = 0x0000;
  95.         dx = 0x184f;/*set 24, 79 for scroll*/
  96.  
  97.         bios(16, &ax, &bx, &cx, &dx);
  98.  
  99. }
  100.  
  101.  
  102.